<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>AdminLTE 2 | General Form Elements</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.7 -->
    <link rel="stylesheet" th:href="@{/adminlte/bower_components/bootstrap/dist/css/bootstrap.min.css}">
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}">
    <!-- Font Awesome -->
    <link rel="stylesheet" th:href="@{/adminlte/bower_components/font-awesome/css/font-awesome.min.css}">
    <!-- Ionicons -->
    <link rel="stylesheet" th:href="@{/adminlte/bower_components/Ionicons/css/ionicons.min.css}">
    <!-- Theme style -->
    <link rel="stylesheet" th:href="@{/adminlte/dist/css/AdminLTE.min.css}">
    <link rel="stylesheet" th:href="@{/bootstrap-table/bootstrap-table.min.css}">
    <!-- AdminLTE Skins. Choose a skin from the css/skins
         folder instead of downloading all of them to reduce the load. -->
    <link rel="stylesheet" th:href="@{/adminlte/dist/css/skins/_all-skins.min.css}">
    <link rel="stylesheet" th:href="@{/bootstrap-table/bootstrap-table.css}">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->

    <script  th:src="@{/js/jquery-3.4.1.min.js}"></script>
    <script  th:src="@{/adminlte/bower_components/jquery/dist/jquery.min.js}"></script>
    <!-- Bootstrap 3.3.7 -->
    <script  th:src="@{/adminlte/bower_components/bootstrap/dist/js/bootstrap.min.js}"></script>
    <script  th:src="@{/layui/layui.js}"></script>
    <!-- FastClick -->
    <script  th:src="@{/adminlte/bower_components/fastclick/lib/fastclick.js}"></script>
    <!-- AdminLTE App -->
    <script  th:src="@{/adminlte/dist/js/adminlte.min.js}"></script>
    <!-- AdminLTE for demo purposes -->
    <script  th:src="@{/adminlte/dist/js/demo.js}"></script>
    <script th:src="@{/bootstrap-table/bootstrap-table.min.js}"></script>
    <script th:src="@{/bootstrap-table/locale/bootstrap-table-zh-CN.js}"></script>

    <!-- Google Font -->
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
</head>
<body class="hold-transition skin-blue sidebar-mini">



    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper" style="margin-left: 200px;">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <h1>
                商品种类 管理
                <small>Preview</small>
            </h1>
            <ol class="breadcrumb">
                <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
                <li><a href="#">Forms</a></li>
                <li class="active">General Elements</li>
            </ol>
        </section>

        <!-- Main content -->
        <section class="content">
            <div class="row">
                <div class="col-xs-12">
                    <div class="box box-info">
                        <div class="box-body">
                            <div id="toolbar">
                                <div class="form-inline" role="form">
                                    <div class="form-group">
                                        <label for="keyword">Keyword: </label>
                                        <input name="keyword"  class="form-control" type="text" id="keyword" placeholder="请输入商品類进行查询">
                                    </div>
                                    <button id="searchBtn" type="submit" class="btn btn-primary" style="margin-left: 5px">
                                    查询
                                </button>
                                    <input type="button" value="刷新" onclick="replaceDoc()" class="btn btn-primary" style="margin-left: 5px">
                                    <a href="/Dictionary/dictionary_insert">
                                        <button id="createBtn" type="submit" class="btn btn-info" style="margin-left: 30px">
                                            插入
                                        </button>
                                    </a>
<!--                                    <a href="/Dictionary/dictionary_add">-->
<!--                                        <button class="btn" id="edit_table_btn"><span class="glyphicon glyphicon-pencil"></span> 编辑</button>-->
<!--                                    </a>-->

<!--                                    <a href="/user/deleteuser">-->
<!--                                        <button id="deleteBtn" type="submit" class="btn btn-danger">删除</button>-->
<!--                                    </a>-->
                                </div>
                            </div>
                            <table id="dataTable" class="table table-hover table-responsive"
                                   style="table-layout: fixed"></table>
                        </div>
                    </div>
                </div>
            </div>
        </section>
        <!-- /.content -->
    </div>
    <!-- /.content-wrapper -->
    <footer class="main-footer">
        <div class="pull-right hidden-xs">
            <b>Version</b> 2.4.0
        </div>
        <strong>Copyright &copy; 2014-2016 <a href="https://adminlte.io">Almsaeed Studio</a>.</strong> All rights
        reserved.
    </footer>

    <!-- Control Sidebar -->
    <aside class="control-sidebar control-sidebar-dark">
        <!-- Create the tabs -->
        <ul class="nav nav-tabs nav-justified control-sidebar-tabs">
            <li><a href="#control-sidebar-home-tab" data-toggle="tab"><i class="fa fa-home"></i></a></li>
            <li><a href="#control-sidebar-settings-tab" data-toggle="tab"><i class="fa fa-gears"></i></a></li>
        </ul>
        <!-- Tab panes -->
        <div class="tab-content">
            <!-- Home tab content -->
            <div class="tab-pane" id="control-sidebar-home-tab">
                <h3 class="control-sidebar-heading">Recent Activity</h3>
                <ul class="control-sidebar-menu">
                    <li>
                        <a href="javascript:void(0)">
                            <i class="menu-icon fa fa-birthday-cake bg-red"></i>

                            <div class="menu-info">
                                <h4 class="control-sidebar-subheading">Langdon's Birthday</h4>

                                <p>Will be 23 on April 24th</p>
                            </div>
                        </a>
                    </li>
                    <li>
                        <a href="javascript:void(0)">
                            <i class="menu-icon fa fa-user bg-yellow"></i>

                            <div class="menu-info">
                                <h4 class="control-sidebar-subheading">Frodo Updated His Profile</h4>

                                <p>New phone +1(800)555-1234</p>
                            </div>
                        </a>
                    </li>
                    <li>
                        <a href="javascript:void(0)">
                            <i class="menu-icon fa fa-envelope-o bg-light-blue"></i>

                            <div class="menu-info">
                                <h4 class="control-sidebar-subheading">Nora Joined Mailing List</h4>

                                <p>nora@example.com</p>
                            </div>
                        </a>
                    </li>
                    <li>
                        <a href="javascript:void(0)">
                            <i class="menu-icon fa fa-file-code-o bg-green"></i>

                            <div class="menu-info">
                                <h4 class="control-sidebar-subheading">Cron Job 254 Executed</h4>

                                <p>Execution time 5 seconds</p>
                            </div>
                        </a>
                    </li>
                </ul>
                <!-- /.control-sidebar-menu -->

                <h3 class="control-sidebar-heading">Tasks Progress</h3>
                <ul class="control-sidebar-menu">
                    <li>
                        <a href="javascript:void(0)">
                            <h4 class="control-sidebar-subheading">
                                Custom Template Design
                                <span class="label label-danger pull-right">70%</span>
                            </h4>

                            <div class="progress progress-xxs">
                                <div class="progress-bar progress-bar-danger" style="width: 70%"></div>
                            </div>
                        </a>
                    </li>
                    <li>
                        <a href="javascript:void(0)">
                            <h4 class="control-sidebar-subheading">
                                Update Resume
                                <span class="label label-success pull-right">95%</span>
                            </h4>

                            <div class="progress progress-xxs">
                                <div class="progress-bar progress-bar-success" style="width: 95%"></div>
                            </div>
                        </a>
                    </li>
                    <li>
                        <a href="javascript:void(0)">
                            <h4 class="control-sidebar-subheading">
                                Laravel Integration
                                <span class="label label-warning pull-right">50%</span>
                            </h4>

                            <div class="progress progress-xxs">
                                <div class="progress-bar progress-bar-warning" style="width: 50%"></div>
                            </div>
                        </a>
                    </li>
                    <li>
                        <a href="javascript:void(0)">
                            <h4 class="control-sidebar-subheading">
                                Back End Framework
                                <span class="label label-primary pull-right">68%</span>
                            </h4>

                            <div class="progress progress-xxs">
                                <div class="progress-bar progress-bar-primary" style="width: 68%"></div>
                            </div>
                        </a>
                    </li>
                </ul>
                <!-- /.control-sidebar-menu -->

            </div>
            <!-- /.tab-pane -->
            <!-- Stats tab content -->
            <div class="tab-pane" id="control-sidebar-stats-tab">Stats Tab Content</div>
            <!-- /.tab-pane -->
            <!-- Settings tab content -->
            <div class="tab-pane" id="control-sidebar-settings-tab">
                <form method="post">
                    <h3 class="control-sidebar-heading">General Settings</h3>

                    <div class="form-group">
                        <label class="control-sidebar-subheading">
                            Report panel usage
                            <input type="checkbox" class="pull-right" checked>
                        </label>

                        <p>
                            Some information about this general settings option
                        </p>
                    </div>
                    <!-- /.form-group -->

                    <div class="form-group">
                        <label class="control-sidebar-subheading">
                            Allow mail redirect
                            <input type="checkbox" class="pull-right" checked>
                        </label>

                        <p>
                            Other sets of options are available
                        </p>
                    </div>
                    <!-- /.form-group -->

                    <div class="form-group">
                        <label class="control-sidebar-subheading">
                            Expose author name in posts
                            <input type="checkbox" class="pull-right" checked>
                        </label>

                        <p>
                            Allow the user to show his name in blog posts
                        </p>
                    </div>
                    <!-- /.form-group -->

                    <h3 class="control-sidebar-heading">Chat Settings</h3>

                    <div class="form-group">
                        <label class="control-sidebar-subheading">
                            Show me as online
                            <input type="checkbox" class="pull-right" checked>
                        </label>
                    </div>
                    <!-- /.form-group -->

                    <div class="form-group">
                        <label class="control-sidebar-subheading">
                            Turn off notifications
                            <input type="checkbox" class="pull-right">
                        </label>
                    </div>
                    <!-- /.form-group -->

                    <div class="form-group">
                        <label class="control-sidebar-subheading">
                            Delete chat history
                            <a href="javascript:void(0)" class="text-red pull-right"><i class="fa fa-trash-o"></i></a>
                        </label>
                    </div>
                    <!-- /.form-group -->
                </form>
            </div>
            <!-- /.tab-pane -->
        </div>
    </aside>
    <!-- /.control-sidebar -->
    <!-- Add the sidebar's background. This div must be placed
         immediately after the control sidebar -->
    <div class="control-sidebar-bg"></div>

    <script>

        $('#dataTable').bootstrapTable({
            method: 'get',//AJAX
            url: "/Dictionary/api/searchdictionary",
            toolbar: '#toolbar',
            striped: true,
            dataField: "dictionaries",
            pageNumber: 1,
            pagination: true,
            queryParamsType: 'limit',
            queryParams: queryParams,
            sidePagination: 'server',
            pageSize: 5,
            pageList: [10, 10, 10, 100],
            showRefresh: true,
            clickToSelect: true,
            toolbarAlign: 'left',
            buttonsAlign: 'right',
            showColumns: true,
            columns: [
                // {
                //     title: '全选',
                //     field: 'select',
                //     checkbox: true,
                //     width: 5,
                //     align: 'center',
                // },
                {
                    title: 'ID',
                    field: 'dId',
                    visible: false,
                    width: 10
                },
                {
                    title: 'name',
                    field: 'name',
                    width: 30,
                    align: 'center'
                },
                {
                    title:'商品类图片' ,
                    field:'path',
                    width:50,
                    align:'center',
                    formatter:function (value, row, index, field) {
                        var str="";
                        str= "<img style=\"height: 50px;width: 50px;\" src=\""+value+"\"/>";
                        return '<img src='+value+' width="50" height="50" class="img-rounded">';
                    }
                },
                {
                    title: 'Edit',
                    width: 50,
                    formatter: function (value, row, index, field) {
                        return [
                            '<a class="edit ml10" href="javascript:void(0)" title="Edit">',
                            '<i class="glyphicon glyphicon-edit"></i>',
                            '</a>',
                        ].join('');
                    },
                    events: {
                        'click .edit': function (e, value, row, index) {
                            //window.location.href = '/Dictionary/dictionary_edit?dId=' + row.dId;
                            edit(row.dId);
                        }
                    },
                    align: 'center'
                },
                {
                    title: 'Delete',
                    width: 50,
                    formatter: function (value, row, index, field) {
                        return [
                            '<a class="cancel ml10" href="javascript:void(0)" title="Delete">',
                            '<i class="glyphicon glyphicon-remove"></i>',
                            '</a>',
                        ].join('');
                    },
                    events: {
                        'click .cancel': function (e, value, row, index) {
                            window.location.href = '/Dictionary/dictionary_delete?dId=' + row.dId;
                        }
                    },
                    align: 'center'
                },
                // {
                //     title: 'Operate',
                //     width: 50,
                //     formatter: function (value, row, index, field) {
                //         return [
                //             '<a class="editP ml10" href="javascript:void(0)" title="Operate">',
                //             '<i class="glyphicon glyphicon-list"></i>',
                //             '</a>',
                //         ].join('');
                //     },
                //     events: {
                //         'click .editP': function (e, value, row, index) {
                //             //window.location.href = '/product/product_list?dId=' + row.dId;
                //             window.location.href = '/product/product_list?dictionaryid=' + row.dId;
                //         }
                //     },
                //     align: 'center'
                // },
            ],
            locale: 'zh-CN',
            responseHandler: function (data) {
                return data;
            }
        });

        function queryParams(params) {
            return {
                pageSize: params.limit,
                pageNum: params.offset / params.limit + 1,
                keyword: $('#keyword').val(),



            }
        }
        function edit(dId) {
            layui.use("layer",function () {
                var layer=layui.layer;
                layer.open({
                    type: 2,
                    title: '编辑信息',
                    maxmin: true,
                    shadeClose: true, //点击遮罩关闭层
                    area : ['600px' , '400px'],
                    content: '/Dictionary/dictionary_edit?dId='+dId
                    })
            })
        }

        $("#deleteBtn").click(function () {
            var selects = $('#dataTable').bootstrapTable('getSelections');
            console.log(selects);
        })

        $("#deleteBtn").click(function () {
            var selects = $('#dataTable').bootstrapTable('getSelections');
            console.log(selects);
        });
        $("#result").click(function () {
             load("back/dictionary-list.html");
        })
        $(document).ready(function () {
            $("#searchBtn").click(function () {
                $('#dataTable').bootstrapTable('refresh');
            });
        })
function replaceDoc() {
    window.location.href='/page/list';
}
    </script>
</body>
</html>
